<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:p="http://primefaces.org/ui"
	template="../template/layout.xhtml">



	<ui:define name="content">
	
		<h1 class="titulo-h1" >Cadastro de Usuário</h1>
		
		<p:panel id="formUsuario" > 
		
			<h:form id="form">
			
					<p:growl globalOnly="true" showDetail="true" autoUpdate="true" />
					<h:inputHidden value="#{usuarioMB.usuario.idUsuario}" />
					<h:panelGrid id="panel" columns="3">
		
					<h:outputText styleClass="formTitulo" value="Dados Pessoais" />
					<p:spacer width="100" height="15" />
					<p:spacer width="100" height="15" />
		
					<p:spacer width="100" height="15" />
					<p:spacer width="100" height="15" />
					<p:spacer width="100" height="15" />
		
					<h:outputText value="Nome completo:" />
					<p:inputText id="nome" required="true" value="#{usuarioMB.usuario.nome}" requiredMessage="Campo Obrigatório!" />
					<p:message for="nome" />
		
					<h:outputText value="CPF:" />
					<p:inputMask id="cpf" mask="999.999.999-99" readonly="false" required="true" requiredMessage="Campo Obrigatório!" value="#{usuarioMB.usuario.cpf}"></p:inputMask>
					<p:message for="cpf" ></p:message>
						
	
					<h:outputText value="Sexo:"></h:outputText>
					<p:selectOneMenu style="width:109px;" required="true" requiredMessage="Selecione um sexo!" id="sexo" value="#{usuarioMB.usuario.sexo}">
						<f:selectItem itemLabel="Selecione..." itemValue="" />
						<f:selectItem itemLabel="Masculino" itemValue="M" />
						<f:selectItem itemLabel="Feminino" itemValue="F" />
					</p:selectOneMenu>
					<p:message for="sexo" />

					<h:outputText value="Perfil:"></h:outputText>
					
					<p:selectOneMenu id="pe" required="true" requiredMessage="Selecione um perfil!" value="#{usuarioMB.usuario.perfil}" converter="perfilConverter">
						<f:selectItem itemLabel="Selecione..." />
						<f:selectItems value="#{perfilMB.listarPerfis()}" var="perfil" itemLabel="#{perfil.nome}" itemValue="#{perfil}"/>
					</p:selectOneMenu>
					<p:message for="pe" />					
	
					<p:spacer width="100" height="15" />
					<p:spacer width="100" height="15" />
					<p:spacer width="100" height="15" />
					
					<h:outputText styleClass="formTitulo" value="Escolha seu login" />
					<p:spacer width="100" height="15" />
					<p:spacer width="100" height="15" />
					
					
					<p:spacer width="100" height="15" />
					<p:spacer width="100" height="15" />
					<p:spacer width="100" height="15" />
	
					<h:outputText value="Login: " />
					<p:inputText id="login" readonly="false" required="true" requiredMessage="Campo Obrigatório!" value="#{usuarioMB.usuario.login}"></p:inputText>
					<p:message for="login" ></p:message>
	
					<h:outputText value="Crie sua senha: " />
					<p:password id="senha" required="true" requiredMessage="Campo Obrigatório!" validatorMessage="Os campos 'Senha' não são iguais!" match="senhaConfirm" value="#{usuarioMB.usuario.senha}" />
					<p:message for="senha" />
					
					
					<h:outputText value="Confirme sua senha: " />
					<p:password id="senhaConfirm" required="true" requiredMessage="Campo Obrigatório!" value="#{usuarioMB.usuario.senha}" />
					<p:message for="senhaConfirm" />
					
					<p:spacer width="100" height="15" />
					<p:spacer width="100" height="15" />
					<p:spacer width="100" height="15" />
					
					<h:outputText styleClass="formTitulo" value="Contato" />
					<p:spacer width="100" height="15" />
					<p:spacer width="100" height="15" />
					
					<p:spacer width="100" height="15" />
					<p:spacer width="100" height="15" />
					<p:spacer width="100" height="15" />
	
					<h:outputText value="E-mail:" />
					<p:inputText id="email" required="true" requiredMessage="Campo Obrigatório!" value="#{usuarioMB.usuario.email}" />
					<p:message for="email" />
	
					<p:spacer width="100" height="15" />
					<p:spacer width="100" height="15" />
					<p:spacer width="100" height="15" />				
	
					<p:commandButton update="panel" action="#{usuarioMB.preperarManipulacao}" value="Salvar" />
					 <p:commandButton value="Voltar" action="#{usuarioMB.listar}" ajax="false" immediate="true"/>
					<p:spacer width="100" height="15" />
	
				</h:panelGrid>
				
			</h:form>
			
		</p:panel>  
	
	</ui:define>

</ui:composition>